import random

import matplotlib.pyplot as plt
import matplotlib.font_manager as fm


a = []
for i in range(500):
    a.append(random.randrange(1, 100))

plt.figure(figsize=(16, 9), dpi=80)
# 计算组数
d = 1
num_bins = (max(a) - min(a)) // d

plt.hist(a, num_bins)


# 设置刻度
plt.xticks(range(min(a), max(a) + d, d))

plt.grid()

plt.show()
